<!--
 * @Author: coman
 * @LastEditors: coman
 * @Date: 2020-06-11 17:24:55
 * @motto: No pain,No gain
 * @LastEditTime: 2020-06-11 17:42:53
--> 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 编写一个函数，计算任意数字的和、差、积、商
要求：使用传参的形式 -->
<script>
    // 1代表加 2代表减 3代表乘 4代表除 
   function sum(){
       var sum =0;
        for(var i=0;i<arguments.length;i++){
            sum+=arguments[i];
        }
        return sum;
   }
   function decrease(){
    var sum =arguments[0];
        for(var i=1;i<arguments.length;i++){
            sum-=arguments[i];
        }
        return sum;
   }
   
   function mutiple(){
    var sum =arguments[0];
        for(var i=1;i<arguments.length;i++){
            sum*=arguments[i];
        }
        return sum;
   }
   
   function chu(){
    var sum =arguments[0];
        for(var i=1;i<arguments.length;i++){
            sum/=arguments[i];
        }
        return sum;
   }
   
    console.log("相加结果为:"+sum(1,2,3,4));
    console.log("相减结果为:"+decrease(1,2,3,4));
    console.log("相乘结果为:"+mutiple(1,2,3,4));
    console.log("相除结果为:"+chu(100,50,25,5));
</script>
</body>
</html>